<template>
	<view class="content">
		<view class="item" v-for="item,index in withdrawList">
			<view class="item-title">
				<text>
					提现账户：{{item.wallet_type}}
				</text>
				<text>
					提现金额：{{item.amount}}
				</text>
				<text class="white">
					{{item.date}}
				</text>
			</view>
			<view class="item-body">
				<text class="huang" v-if="item.status == '通过'">
					【提现成功】
				</text>
				<text class="red" v-if="item.status == '拒绝'">
					【提现拒绝】
				</text>
				<text v-if="item.status == '待审核'">
					【等待审核】
				</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				withdrawList:null,
				userInfo:null,
				user_token:null
			};
		},
		onLoad() {
			this.getUserInfo()
			this.getWithdrawLog()
		},
		methods:{
			getUserInfo(){
				let that = this
				if(that.userInfo == null){
					uni.getStorage({
						key: 'user_token',
						success: function (res) {
							that.user_token = res.data
							that.checkUser()
						},
						fail: function(res){
							uni.showToast({
								title:'请先登录',
								icon:'none',
								success() {
									uni.redirectTo({
										url:'/pages/login/login',
									})
								}
							})
							
						}
					});
				}
			},
			checkUser(){
				let that = this
				uni.request({
					url:getApp().globalData.baseUrl + '/api/user/getUserInfo',
					method:'POST',
					header: {token:that.user_token},
					success(res) {
						if(res.data.code == 401){
							uni.removeStorage({
								key:'user_token',
								success() {
									uni.showToast({
										icon:'none',
										title:'登录已失效,请重新登录',
										success() {
											setTimeout(function(){
												uni.redirectTo({
													url:'/pages/login/login'
												})
											})
										}
									})
								}
							})
						}
						that.userInfo = res.data.data
					},
					fail() {
						uni.showToast({
							title:'网络错误',
							icon:'none',
						})
					}
				})
			},
			getWithdrawLog(){
				let that = this
				uni.request({
					url:getApp().globalData.baseUrl + '/api/withdraw/index',
					method:'POST',
					header: {token:that.user_token},
					success(res) {
						that.withdrawList = res.data.data
					},
					fail() {
						uni.showToast({
							title:'网络错误',
							icon:'none',
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #f4f4f4;
	}
	
	.content{
		margin-top: .7rem;
		display: flex;
		justify-content: center;
		flex-direction: column;
		font-size: .7rem;
	}
	
	.item{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 1rem;
		background: white;
		border-bottom: 1px solid #f6f6f6 !important;
	}
	
	.item-title{
		// width: 40%;
		display: flex;
		flex-direction: column;
		justify-content: center;
	}
	.item-title>text{
		padding: .2rem;
	}
	
	.item-body{
		display: flex;
		flex-direction: column;
	}
	
	.red{
		color: #fe0000 !important;
		font-weight: bold;
	}
	.huang{
		color:#FF9000;
		background: #FEF5EA;
	}
	
	.white{
		color: #90949E;
	}
</style>
